define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'platcourse/index' + location.search,
                    add_url: 'platcourse/add',
                    edit_url: 'platcourse/edit',
                    del_url: 'platcourse/del',
                    multi_url: 'platcourse/multi',
                    table: 'learn_course',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        //{checkbox: true},
                        {field: 'id', title: __('Id')},
                        // {field: 'number', title: __('Number')},
                        {field: 'name', title:'课程名称'},
                        // {field: 'introduce', title: __('Introduce')},
                        {field: 'origin_price', title: '原价', operate:false},
                        {field: 'price', title: '现价', operate:false},
                        // {field: 'visitor_origin_price', title: __('Visitor_origin_price'), operate:'BETWEEN'},
                        // {field: 'visitor_price', title: __('Visitor_price'), operate:'BETWEEN'},
                        // {field: 'buy_numbers', title: __('Buy_numbers')},
                        {field: 'image', title: '封面', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'thumbs', title: __('Thumbs')},
                        // {field: 'author', title: __('Author')},
                        // {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
                        // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'org_cate_id', title: __('Org_cate_id')},
                        // {field: 'type', title: __('Type')},
                        // {field: 'is_buy', title: __('Is_buy'), searchList: {"0":__('Is_buy 0'),"1":__('Is_buy 1')}, formatter: Table.api.formatter.normal},
                        {field: 'sort', title: '排序'},
                        // {field: 'is_chat', title: __('Is_chat'), searchList: {"0":__('Is_chat 0'),"1":__('Is_chat 1')}, formatter: Table.api.formatter.normal},
                        // {field: 'file', title: __('File')},
                        // {field: 'teacher_id', title: __('Teacher_id')},
                        // {field: 'is_single', title: __('Is_single')},
                        // {field: 'is_system', title: __('Is_system')},
                        // {field: 'adminid', title: __('Adminid')},
                        // {field: 'series_id', title: __('Series_id')},
                        // {field: 'special', title: __('Special')},
                        // {field: 'is_hot', title: __('Is_hot')},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                pagination: false,
                showToggle: false,
                showColumns: false,
                showExport: false,
                searchFormVisible: false,
                search:false,
                commonSearch:false,
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});